package ${package}.${moduleName}.controller;



import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper;
import com.kingxunlian.scf.domain.common.PageParameter;
import com.kingxunlian.scf.common.controller.BaseController;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;




/**
 * ${comments}
 * 
 * @author ${author}
 * @email ${email}
 * @date ${datetime}
 */
@RestController
@RequestMapping("/${pathName}")
public class ${className}Controller extends BaseController {
	private Logger logger = LoggerFactory.getLogger(this.getClass());

	@Autowired
	private ${className}Service ${classname}Service;
	
	/**
	 * 列表
	 */
	@RequestMapping(value = "/list", method = RequestMethod.GET)
	public XLBaseResponse<List<${className}Dto>> list(@RequestParam ${className}Dto ${classname}Dto){

    	logger.info("list, req: {} ", JSONObject.toJSON(${classname}Dto));

    	List<${className}Dto> ${classname}List = ${classname}Service.queryByCondition(${classname}Dto);

		return XLBaseResponse.newInstance(${classname}List);
	}

    /**
    * 列表--分页
    */
    @RequestMapping(value = "/page", method = RequestMethod.GET)
    public XLBaseResponse<Page<${className}Dto>> page(@RequestParam ${className}Dto ${classname}Dto,  @ModelAttribute("page") PageParameter pageParameter){

        logger.info("page, req: {} ", JSONObject.toJSON(${classname}Dto));

        Page page = ${classname}Service.queryByPage(${classname}Dto,pageParameter);

        return XLBaseResponse.newInstance(page);
	}

	
	/**
	 * 保存
	 */
	@RequestMapping(value = "/insert", method = RequestMethod.POST)
	public XLBaseResponse insert(@RequestBody ${className}Dto ${classname}Dto){
		${classname}Service.insertSelective(${classname}Dto);
        return XLBaseResponse.setOk();
	}
	
	/**
	 * 修改
	 */
	@RequestMapping(value = "/update", method = RequestMethod.POST)
	public XLBaseResponse update(@RequestBody ${className}Dto ${classname}Dto){
		${classname}Service.updateSelective(${classname}Dto);
		return XLBaseResponse.setOk();
	}

    /**
    * 删除
    */
    @RequestMapping(value = "/delete", method = RequestMethod.POST)
    public XLBaseResponse delete(@RequestBody ${pk.attrType} ${pk.attrname}){
		${classname}Service.deleteByPrimaryKey(${pk.attrname});
        return XLBaseResponse.setOk();
    }
	/**
	 * 删除
	 */
	@RequestMapping(value = "/deleteBatch", method = RequestMethod.POST)
	public XLBaseResponse deleteBatch(@RequestBody List<${pk.attrType}> ${pk.attrname}List){
		${classname}Service.deleteBatchByPrimaryKey(${pk.attrname}List);
        return XLBaseResponse.setOk();
	}
	
}
